{include file="public/base" /}
{block name="main"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>修改管理员-权限组</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form method="get" action="javascript:;" class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">管理员</label>
                            <div class="col-sm-10">
                                <select name="isadmin" class="form-control">
                                    {volist name="alladmin" id="v"}
                                    <option value="{$v.id}" {if $one.id==$v.id} selected {/if}>{$v.account}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="mail-body">
                            <h4>权限组：</h4>
                            <p>
                                {volist name="allgroup" id="k"}
                                <label class="checkbox-inline">
                                    <input type="checkbox"   name="groupid[]" value="{$k.id}" {if in_array($k.id,$one.groupid)} checked="checked" {/if} >{$k.name}
                                </label>
                                {/volist}
                            </p>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit" onclick="edit()">保存内容</button>
                                <!--<button class="btn btn-white" type="submit">取消</button>-->
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="javascript"}
<script src="ADMIN_JS/content.min.js?v=1.0.0"></script>
<script src="ADMIN_JS/plugins/iCheck/icheck.min.js"></script>
<script>
    function edit()
    {
        var loading = layer.msg('正在提交数据，请稍后...', {icon: 16,time:3000});
        var obj = document.getElementsByName("groupid[]");
        var check_val = [];
        for(k in obj){
            if(obj[k].checked)
                check_val.push(obj[k].value);
        }
        $.ajax({
            type:'post',
            url:'{:url("admin/upgroup",["id"=>$one.id])}',
            data:{'groupids':check_val},
            success:function(data){
                layer.close(loading);
                if(data.code==1){
                    layer.msg(data.msg,{icon:6,time:1500});
                    setTimeout(function(){window.parent.location.reload();},1000);
                }else{
                    layer.msg(data.msg,{icon:5,time:1500});
                }
            }
        })
    }

</script>
{/block}